using UnityEngine;
using System.Collections;

public class PowerupScript : MonoBehaviour {


    public AudioClip audioPowerup;

	// Use this for initialization
	void Start () {
		transform.position=Vector3.zero;
		transform.Rotate(new Vector3(Random.Range(0,360),Random.Range(0,360),Random.Range(0,360)));
		transform.Translate(new Vector3(0,Balance.SPHERE_RADIUS+1f,0),Space.Self);
	}
	
	// Update is called once per frame
	void Update () {
	    transform.Rotate(new Vector3(0,10*Time.deltaTime,0));
	}
    public Item itemName;
    void OnTriggerEnter(Collider other)
    {
        if (other.name == "Builder" || other.name == "Destroyer")
        {
            other.GetComponent<Player>().setItem(itemName);
        }
        audio.PlayOneShot(audioPowerup);
        Destroy(gameObject);
    }
}
